import React from 'react';
import css from './index.less';
import PageContentPreview from 'components/pageContentPreview';
import PropTypes from 'prop-types';
import { observer } from 'mobx-react';

@observer
export default class Page extends React.Component {

  static propTypes = {
    mod: PropTypes.object.isRequired
  };

  renderPageBg() {
    const { mod } = this.props;
    const props = {
      className: css.pageBg,
      style: mod.style,
    };
    return (
      <div {...props} />
    );
  }

  renderContent() {
    // const { mod, scale } = this.props;
    // console.log('scale', scale);
    return (
      <PageContentPreview {...this.props}/>
    );
  }

  render() {
    const { mod } = this.props;
    if (!mod) {
      return (
        <div>
          页面渲染失败
        </div>
      );
    }

    const props = {
      className: css.page,
      style: {
        backgroundColor: mod.backgroundColor,
      }
    };

    return (
      <div {...props}>
        {
          // this.renderPageBg()
        }
        {this.renderContent()}
      </div>
    );
  }
}
